
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
typedef struct s
{
	int value;
	int index;
}pp;
pp a1[N];
int a2[N];
int a3[N];
int n, k;
template<class T>
class compare
{
public:
	bool operator()(const T& a, const T& b)
	{
		if (a.value != b.value)
		{
			return a.value < b.value;
		}
		else
		{
			return a.index > b.index;
		}
	}
};
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n>>k;
	priority_queue<pp,vector<pp>,compare<pp>> q;
	for (int i = 1; i <= n; i++)
	{
		int tem;
		cin >> tem;
		a2[i] = tem;
		a3[i] = -1;
		a1[i].value = tem;
		a1[i].index = i;
		q.push(a1[i]);
	}
	while (!q.empty())
	{
		pp f = q.top();
		q.pop();
		cout << f.value << " " << f.index << endl;
	}
	return 0;
}


